#include "Particle.h"

Particle::Particle(const Vector3& _position, double _invMass = 0) :
	position(_position), oldPosition(_position), invMass(_invMass)
{
	acceleration = 0;
	damping = 0;
}

void Particle::verlet(double timeStep)
{
	// Apply damping: acc -= velocity*(damping/mass)
	Vector3 v = position - oldPosition;
	Vector3 a = acceleration - v*damping*invMass;
	// Move particle: newPosition = curPosition + velocity + a*t*t
	Vector3 tmp = position;
	position = tmp + v + a*timeStep*timeStep;
	oldPosition = tmp;
}

